define(['app'],function(app){return {module: function($scope, $http, eventBusService, httpService, params) {
	
	$scope.form.fk_group = params.fk_group;
	
	httpService.post(app.urls.role_group_selectById,{"id":params.fk_group},function(data){
		if("0000" === data.code){
			$scope.form.type = data.data.type;
		}else{
			alert(data.msg);
		}
	});
	
	$scope.saveForm = function(){
		if($scope.formCheck()){
			httpService.post(app.urls.role_selectIfExit,$scope.form,function(data){
				if("0000" === data.code){
					if(data.data.length == 0){
						httpService.post(app.urls.role_insert,$scope.form,function(data){
							if("0000" === data.code){
								eventBusService.publish("content.pageGroup.reload",data.data);
								eventBusService.publish("modal.page.close",{});
				    		}else{
				    			alert(data.msg);
				    		}
						});
					}else{
						alert("该角色已存在");
					}						
	    		}else{
	    			alert(data.msg);
	    		}
			});
		}
	}
}}});